/*
 * @Description: 表单校验规则
 * @Author: chenju
 * @Date: 2022-03-22 17:46:03
 * @LastEditors: qingyang
 * @LastEditTime: 2023-01-10 11:05:09
 */
// const validateFile = async (rule: any, value: any[], callback: any) => {
//   console.log('value', value);
//   if (value.length == 0) {
//     callback(new Error('请上传文件'));
//     return;
//   }
//   const file = value[0];
//   const fileUrl = file ? file?.url ?? file.response?.data?.fileUrl : '';
//   const fileName = file?.name;
//   console.log('validateFile', file, fileUrl, fileName);
//   if (value.length && (!fileUrl || !fileName)) {
//     callback(new Error('文件上传异常，请删除后重新上传'));
//   } else {
//     callback();
//   }
// };
export const rules = {
  factorName: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],
  enName: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],
  category: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],
  emissionFactor: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],
  factorUnit: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],
  country: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],
  baseYear: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],

  factorSource: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ],
  fileList: [
    {
      required: true,
      message: '必填项',
      trigger: ['submit', 'change']
    }
  ]
};

export const dataUnitOption = [
  {
    value: 'g',
    label: 'g'
  },
  {
    value: 't',
    label: 't'
  },
  {
    value: 'kg',
    label: 'kg'
  },
  {
    value: 'L',
    label: 'L'
  },
  {
    value: 'm³',
    label: 'm³'
  },
  {
    value: 'kWh',
    label: 'kWh'
  },
  {
    value: 'MWh',
    label: 'MWh'
  },
  {
    value: 'GJ',
    label: 'GJ'
  }
];

export const unitOption = [
  {
    value: 'g/g',
    label: 'g/g'
  },
  {
    value: 't/t',
    label: 't/t'
  },
  {
    value: 'kg/kg',
    label: 'kg/kg'
  },
  {
    value: 'kg/L',
    label: 'kg/L'
  },
  {
    value: 'kg/m³',
    label: 'kg/m³'
  },
  {
    value: 'kg/kWh',
    label: 'kg/kWh'
  },
  {
    value: 't/MWh',
    label: 't/MWh'
  },
  {
    value: 't/GJ',
    label: 't/GJ'
  },

  {
    value: 'kg/t·km',
    label: 'kg/t·km'
  },
  {
    value: 'kg/person·km',
    label: 'kg/person·km'
  },
  {
    value: 'kg/km',
    label: 'kg/km'
  },
  {
    value: 'kg/mile',
    label: 'kg/mile'
  },
  {
    value: 't/vehicle',
    label: 't/vehicle'
  },
  {
    value: 'kg/unit',
    label: 'kg/unit'
  },
  {
    value: 'kg/ha',
    label: 'kg/ha'
  },
  {
    value: 'kg/head·yr',
    label: 'kg/head·yr'
  }
];
